package com.mymoney.adapters;

import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.mymoney.ws.data.ItemBean;

public class ListAdapter extends ArrayAdapter<ItemBean>{
	
	private ItemBean[] objects;
	private final Context context;
	
	public ListAdapter(Context context, int resource, int textViewResourceId,
			ItemBean[] objects) {
		super(context, resource, textViewResourceId, objects);
		this.context = context;
		this.objects = objects;
	}

	public int getCount() {
		return objects.length;
	}

	public ItemBean getItem(int position) {
		return objects[position];
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		ItemBean obj = objects[position];

	    TextView tv = new TextView(context);
	    tv.setText(obj.getName()); 
	    
	    //Set whatever typeface you want here as well
	    
	    //Set Text color
	    tv.setTextColor(Color.BLACK);
	    
	    //Set Text Size
	    tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP,22);
	    
	    //Set Padding
	    tv.setPadding(50, 20, 0, 20);
	    
	    //Set Font
	    Typeface tf = Typeface.createFromAsset(context.getAssets(),
                "fonts/SEGOE.TTF");
	    tv.setTypeface(tf);
	    
	    return tv;
	}

}
